<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'area-index', //页面标示
    'pagename' => '小区列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
		
        <div class="row">

			<!-- table 11 -->
			<div class="col-lg-12"> 
            <!---->

            <div class="block">
            	<a class="btn btn-default" href="<?php echo U('village/search');?>" rel="pop">添加小区</a>
                <a class="btn btn-default" href="<?php echo U('area/index');?>">返回列表</a>
            </div>
            <!---->
				<section class="panel"> 
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							<thead>
                              <tr>
                                <th align="center" width="100">ID</th>
                                <th align="center" width="150">城市</th>
                                <th align="center">小区名称</th>
                                <th align="center" width="150">操作</th>
                              </tr>
                            </thead>
                            <tbody>
                            <?php
                            if ($rs){
                                foreach($rs as $val){
                            ?>
                              <tr id="list_detail_<?php echo $val['vid'];?>">
                                <td><?php echo $val['vid'];?></td>
                                <td><?php echo $val['city_name'];?></td>
                                <td><?php echo $val['title'];?></td>
                                <td>
                                <div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                    <ul class="dropdown-menu">
                                        <li><a href="<?php echo U('village/edit',array('id'=>$val['vid']));?>">编辑</a></li>
                                        <li><a href="javascript:;" rel="<?php echo $val['vid'];?>" class="delarea">清除社区关系</a></li>
                                        <li><a href="javascript:;" rel="<?php echo $val['vid'];?>" class="delete">删除</a></li>
                                    </ul> 
								</div>
                                </td>
                              </tr>
                              <?php
                                }
                            }else{
                              ?>
                             <tr>
                                <td colspan="8" align="center">暂无数据</td>
                              </tr>
                            <?php
                            }
                            ?>
                            </tbody> 
						</table> 
					</div> 
 					<footer class="panel-footer"> 
						<div class="row"> 
							<div class="col-sm-12 text-right text-center-sm"> 
									<?php echo page($total,$p,'',20,'p');?>
							</div> 
						</div> 
					</footer>
				</section> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
function setVillage(vid,aname,aid){
		console.log(vid);
		console.log(aname);
		console.log(aid);
		Msg.loading('正在处理...');
		$.post('<?php echo U('village/setcommunity');?>',{"vid":vid,"community_id":<?php echo $fid;?>},function(res){
			Msg.hide();
			if (res.status==1){
				Msg.ok('操作成功',function(){
					document.location.reload();	
				},1000);
			}else{
				Msg.error(res.info);
			}
		},'json');
}
$(function(){
	$('.delarea').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认清除小区从属关系吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('village/delarea');?>',{"id":id},function(result){
				  Msg.hide();
				  $("#list_detail_"+id).fadeOut();
			  },'json');
		  },
		  //点击取消返回callback
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();//取消弹出层对对话框的遮蔽
	  return false;
	})
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除该小区吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('village/delete');?>',{"id":id},function(result){
				  Msg.hide();
				  $("#list_detail_"+id).fadeOut();
			  },'json');
		  },
		  //点击取消返回callback
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();//取消弹出层对对话框的遮蔽
	  return false;
	})
})
</script>
<?php
include getTpl('footer', 'public');
?>